oracle.pg.text.lucene

## Class LuceneIndex<T extends Element>

- java.lang.Object
- - oracle.pg.text.lucene.LuceneIndex<T>

- All Implemented Interfaces:
    Index<T>, OracleIndex<T>
  Direct Known Subclasses:
    LuceneAutoIndex, LuceneEdgeIndex, LuceneVertexIndex

      public abstract class LuceneIndex<T extends Element>
      extends Object
      implements OracleIndex<T>

  An abstract class implementing the Blueprints Index interface.

- - ### Field Summary

    - ### Fields inherited from interface oracle.pg.text.OracleIndex

      `EDGE_ID_PROP, EDGE_LABEL_PROP, END_NODE_ID_PROP, START_NODE_ID_PROP, TYPE_DT_BOOL, TYPE_DT_DATE, TYPE_DT_DOUBLE, TYPE_DT_FLOAT, TYPE_DT_INTEGER, TYPE_DT_SERIALIZABLE, TYPE_DT_STRING, VERTEX_ID_PROP`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LuceneIndex(String indexName, Class<T> indexClass, OraclePropertyGraphBase oraclePropertyGraph, Parameter[] indexParameters, boolean clear)` Constructs a new LuceneIndex object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(T element)` Adds a new Element into the Element Index
    `void` | `addToDeleteCache(Long id, int indexDir)` Add the specified element to the delete cache for future removal
    `String` | `buildSearchTerm(String key, Object value)` Builds a search term query expression in the syntax required by this index.
    `String` | `buildSearchTerm(String key, Object value, Class dtValue)` Builds a search term query expression in the syntax required by this index.
    `void` | `clearIndex()` Clears all data stored in the index.
    `void` | `close()` Closes this LuceneIndex object
    `void` | `commit()` Commit changes
    `long` | `count(String key, Object value)` Counts all the matching elements that have a particular key/value property within the index
    `long` | `count(String key, Object value, boolean acceptWildcard)` Counts all the matching elements that have a particular key/value property within the index
    `long` | `count(String key, Object value, Class dtValue, boolean acceptWildcard)` Counts all the matching elements that have a particular key/value property within the index
    `void` | `deleteExistingDirectories(String[] indexLocation)` Delete existing directories where the Lucene index is stored.
    `void` | `dropIndex()` Clears all data stored in the index.
    `CloseableIterable<T>` | `get(String key, Object value)` Gets an Iterable object with all the matching elements that have a particular key/value property within the index
    `CloseableIterable<T>` | `get(String key, Object value, boolean acceptWildcard)` Gets an Iterable object with all the matching elements that have a particular key/value property within the index
    `abstract CloseableIterable<T>` | `get(String key, Object value, Class dtValue, boolean acceptWildcard)` Gets an Iterable object with all the matching elements that have a particular key/value property within the index
    `org.apache.lucene.store.Directory` | `getDirectory(int index)` Get a `Directory` object for the specified subdirectory ID.
    `String` | `getDirectoryName()` Gets the directory name for this index.
    `String` | `getDocIdentifier()` Get index document's identifier.
    `String` | `getGraphName()` Get the name of the associated graph
    `Class<T>` | `getIndexClass()` Gets the class associated to this index
    `String` | `getIndexName()` Gets the name of this index instance.
    `LuceneParameters` | `getIndexParameters()` Gets the index parameters associated to this index.
    `OracleDirectory` | `getOracleDirectory()` Gets the Oracle Directory storing all index data.
    `OracleIndexParameters` | `getOracleIndexParameters()` Gets the OracleIndexParameters associated to this index
    `org.apache.lucene.search.SearcherManager` | `getOracleSearcherManager(int index)` Gets the SearcherManager object that executes read operations over the index stored in the specified directory.
    `Parameter<String,Object>[]` | `getParameters()` Gets the Parameters associated to this index.
    `CloseableIterable<T>[]` | `getPartitioned(Object[] connections, String key, Object value, boolean acceptWildcard, int startShardId)` Gets an array of `CloseableIterable` objects that hold all the elements with an attribute matching the given K/V pair.
    `abstract CloseableIterable<T>[]` | `getPartitioned(Object[] connections, String key, Object value, Class dtValue, boolean acceptWildcard, int startShardId)` Gets an array of `CloseableIterable` objects that hold all the elements with an attribute matching the given K/V pair.
    `org.apache.lucene.search.SearcherFactory` | `getSearcherFactory()` Gets the searcher factory associated to this index
    `int` | `getTotalShards()` Gets the number of shards (sub-directories) in this index.
    `boolean` | `isAutoIndex()` Returns true if this is an auto index
    `boolean` | `isDelBatchEmpty()` Verifies if the deletes batch associated to this index is empty.
    `boolean` | `isDelBatchFull()` Verifies if the deletes batch associated to this index is full.
    `boolean` | `isUpdatesBatchEmpty()` Verifies if the updates batch associated to this index is empty.
    `boolean` | `isUpdatesBatchFull()` Verifies if the updates batch associated to this index is full.
    `void` | `put(String key, Object value, T element)` Indexes an element by a key and a value.
    `void` | `put(String key, Object value, T element, OracleIndexWriter[] indexWriters)` Indexes an element by a key and a value.
    `CloseableIterable<T>` | `query(String key, Object value)` Query for all the elements satisfying the specified K/V property within the index
    `CloseableIterable<T>` | `query(String key, Object value, boolean useWildcards)` Query for all the elements satisfying the specified K/V property within the index
    `void` | `remove(String key, Object value, Class dtValue, T element, OracleIndexWriter[] indexWriters)` Removes an element indexed by a particular key/value.
    `void` | `remove(String key, Object value, T element)` Removes an element indexed by a particular key/value.
    `void` | `remove(String key, Object value, T element, OracleIndexWriter[] indexWriters)` Removes an element indexed by a particular key/value.
    `void` | `remove(T element)` Deletes a element from this index
    `void` | `removeAll(String key)` Removes all the elements from the index matching the specified key.
    `void` | `removeAll(String key, OracleIndexWriter[] indexWriters)` Removes all the elements from the index matching the specified key.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface oracle.pg.text.OracleIndex

      `refreshIndex`

- - ### Constructor Detail

    - #### LuceneIndex

          public LuceneIndex(String indexName,
                     Class<T> indexClass,
                     OraclePropertyGraphBase oraclePropertyGraph,
                     Parameter[] indexParameters,
                     boolean clear)

      Constructs a new LuceneIndex object.
      Parameters:
        `indexName` - the name of the index
        `indexClass` - the element class that this index is indexing (can be base class)
        `oraclePropertyGraph` - an `OraclePropertyGraphBase` object.
        `indexParameters` - a collection of parameters for the underlying index implementation.
        `clear` - a boolean specifying if the index should be cleared at the beginning.

  - ### Method Detail

    - #### add

          public void add(T element)

      Adds a new Element into the Element Index
      Specified by:
        `add` in interface `OracleIndex<T extends Element>`
      Parameters:
        `element` - an `Element` object.
      Throws:
        `IOException`

    - #### addToDeleteCache

          public void addToDeleteCache(Long id,
                              int indexDir)

      Add the specified element to the delete cache for future removal
      Parameters:
        `id` - the id of the element to remove.
        `indexDir` - the number of directory where the element is stored.

    - #### buildSearchTerm

          public String buildSearchTerm(String key,
                               Object value)

      Builds a search term query expression in the syntax required by this index.
      Specified by:
        `buildSearchTerm` in interface `OracleIndex<T extends Element>`
      Parameters:
        `key` - the key of the K/V property
        `value` - the value object of the K/V property

    - #### buildSearchTerm

          public String buildSearchTerm(String key,
                               Object value,
                               Class dtValue)

      Builds a search term query expression in the syntax required by this index.
      Specified by:
        `buildSearchTerm` in interface `OracleIndex<T extends Element>`
      Parameters:
        `key` - the key of the K/V property
        `value` - the value object of the K/V property
        `dtValue` - class of the value object

    - #### clearIndex

          public void clearIndex()

      Clears all data stored in the index.
      Specified by:
        `clearIndex` in interface `OracleIndex<T extends Element>`

    - #### close

          public void close()

      Closes this LuceneIndex object
      Specified by:
        `close` in interface `OracleIndex<T extends Element>`

    - #### commit

          public void commit()

      Commit changes
      Specified by:
        `commit` in interface `OracleIndex<T extends Element>`

    - #### count

          public final long count(String key,
                   Object value)

      Counts all the matching elements that have a particular key/value property within the index
      Specified by:
        `count` in interface `Index<T extends Element>`
      Parameters:
        `key` - the name of the property. It MUST not be NULL. If the key is not found in the index, the result will be 0.
        `value` - the value object of the property. It can be NULL which will cause all edges with the given key to be returned.
      Returns:
        a `CloseableIterable` object.

    - #### count

          public final long count(String key,
                   Object value,
                   boolean acceptWildcard)

      Counts all the matching elements that have a particular key/value property within the index
      Specified by:
        `count` in interface `OracleIndex<T extends Element>`
      Parameters:
        `key` - the name of the property. It MUST not be NULL. If the key is not found in the index, the result will be 0.
        `value` - the value object of the property. It can be NULL which will cause all edges with the given key to be returned.
        `acceptWildcard` - specifies if wild cards can be used in the value object. the index
      Returns:
        a `CloseableIterable` object.

    - #### count

          public long count(String key,
                   Object value,
                   Class dtValue,
                   boolean acceptWildcard)

      Counts all the matching elements that have a particular key/value property within the index
      Specified by:
        `count` in interface `OracleIndex<T extends Element>`
      Parameters:
        `key` - the name of the property. It MUST not be NULL. If the key is not found in the index, the result will be 0.
        `value` - the value object of the property. It can be NULL which will cause all edges with the given key to be returned.
        `dtValue` - the class representing the datatype of the property value. This can be used to cast the property value to a different datatype. For example, if the value is "3.01" and dtValue is Float.Class, then this value will be treated as a 3.01f.
        `acceptWildcard` - specifies if wild cards can be used in the value object. the index
      Returns:
        a `CloseableIterable` object.

    - #### deleteExistingDirectories

          public void deleteExistingDirectories(String[] indexLocation)

      Delete existing directories where the Lucene index is stored.
      Parameters:
        `indexLocation` - the file paths of the sub-directories to remove.

    - #### dropIndex

          public void dropIndex()

      Clears all data stored in the index.
      Specified by:
        `dropIndex` in interface `OracleIndex<T extends Element>`

    - #### get

          public final CloseableIterable<T> get(String key,
                                 Object value)

      Gets an Iterable object with all the matching elements that have a particular key/value property within the index
      Specified by:
        `get` in interface `Index<T extends Element>`
      Parameters:
        `key` - the name of the property. It MUST not be NULL. If the key is not found in the index, the result will be 0.
        `value` - the value object of the property. It can be NULL which will cause all edges with the given key to be returned.
      Returns:
        a `CloseableIterable` object.

    - #### get

          public final CloseableIterable<T> get(String key,
                                 Object value,
                                 boolean acceptWildcard)

      Gets an Iterable object with all the matching elements that have a particular key/value property within the index
      Specified by:
        `get` in interface `OracleIndex<T extends Element>`
      Parameters:
        `key` - the name of the property. It MUST not be NULL. If the key is not found in the index, the result will be 0.
        `value` - the value object of the property. It can be NULL which will cause all edges with the given key to be returned.
        `acceptWildcard` - specifies if wild cards can be used in the value object. the index
      Returns:
        a `CloseableIterable` object.

    - #### get

          public abstract CloseableIterable<T> get(String key,
                                 Object value,
                                 Class dtValue,
                                 boolean acceptWildcard)

      Gets an Iterable object with all the matching elements that have a particular key/value property within the index
      Specified by:
        `get` in interface `OracleIndex<T extends Element>`
      Parameters:
        `key` - the name of the property. It MUST not be NULL. If the key is not found in the index, the result will be 0.
        `value` - the value object of the property. It can be NULL which will cause all edges with the given key to be returned.
        `dtValue` - the class representing the datatype of the property value. This can be used to cast the property value to a different datatype. For example, if the value is "3.01" and dtValue is Float.Class, then this value will be treated as a 3.01f.
        `acceptWildcard` - specifies if wild cards can be used in the value object. the index
      Returns:
        a `CloseableIterable` object.

    - #### getDirectory

          public org.apache.lucene.store.Directory getDirectory(int index)

      Get a `Directory` object for the specified subdirectory ID.
      Parameters:
        `index` - the subdirectory ID. The directories in the Lucene index are a positive number from the range of [0 to N - 1] where N is the total number of subdirectories.

    - #### getDirectoryName

          public final String getDirectoryName()

      Gets the directory name for this index.
      Specified by:
        `getDirectoryName` in interface `OracleIndex<T extends Element>`
      Returns:
        the directory name for this index.

    - #### getDocIdentifier

          public String getDocIdentifier()

      Get index document's identifier.
      Specified by:
        `getDocIdentifier` in interface `OracleIndex<T extends Element>`
      Returns:
        a String representing the document's identifier based on the entity type it handles (edge or vertex).

    - #### getGraphName

          public final String getGraphName()

      Get the name of the associated graph
      Specified by:
        `getGraphName` in interface `OracleIndex<T extends Element>`

    - #### getIndexClass

          public final Class<T> getIndexClass()

      Description copied from interface: `OracleIndex`
      Gets the class associated to this index
      Specified by:
        `getIndexClass` in interface `Index<T extends Element>`
      Specified by:
        `getIndexClass` in interface `OracleIndex<T extends Element>`
      Returns:
        Vertex.class if this is a vertex index or Edge.class if this is an Edge index.

    - #### getIndexName

          public final String getIndexName()

      Gets the name of this index instance.
      Specified by:
        `getIndexName` in interface `Index<T extends Element>`
      Returns:
        the name of this index.

    - #### getIndexParameters

          public LuceneParameters getIndexParameters()

      Gets the index parameters associated to this index.
      Returns:
        an `LuceneParameters` object.

    - #### getOracleDirectory

          public OracleDirectory getOracleDirectory()

      Gets the Oracle Directory storing all index data. This directory is obtained based on the configurations specified in the index parameters.
      Returns:
        an `OracleDirectory` object.

    - #### getOracleIndexParameters

          public OracleIndexParameters getOracleIndexParameters()

      Description copied from interface: `OracleIndex`
      Gets the OracleIndexParameters associated to this index
      Specified by:
        `getOracleIndexParameters` in interface `OracleIndex<T extends Element>`

    - #### getOracleSearcherManager

          public org.apache.lucene.search.SearcherManager getOracleSearcherManager(int index)
                                                                            throws IOException

      Gets the SearcherManager object that executes read operations over the index stored in the specified directory.
      Parameters:
        `index` - the subdirectory ID. The directories in the Lucene index are a positive number from the range of [0 to N - 1] where N is the total number of subdirectories.
      Returns:
        a `SearcherManager` object.
      Throws:
        `IOException`

    - #### getParameters

          public Parameter<String,Object>[] getParameters()

      Gets the Parameters associated to this index.
      Specified by:
        `getParameters` in interface `OracleIndex<T extends Element>`
      Returns:
        a `Parameter` array.

    - #### getPartitioned

          public final CloseableIterable<T>[] getPartitioned(Object[] connections,
                                              String key,
                                              Object value,
                                              boolean acceptWildcard,
                                              int startShardId)

      Gets an array of `CloseableIterable` objects that hold all the elements with an attribute matching the given K/V pair. Each element in the `CloseableIterable` array uses a separate connection provided to fetch a subset of the results from a corresponding Lucene sub-directory. Note that we assign an integer ID (in the range of [0, N - 1]) to all the sub-directories in a Lucene index with N shards. The subset of shards (subdirectories) queried will consist of those shards with ID value in the range of [startShardId, startShardId - 1 + size of connections array].
      Specified by:
        `getPartitioned` in interface `OracleIndex<T extends Element>`
      Parameters:
        `connections` - an array of connections to the index. Each element of this array should be of type SearcherManager. See `getOracleSearcherManager(int)`.
        `key` - the key of a property
        `value` - the value object of the property.
        `acceptWildcard` - specifies if wild cards can be used in the value object.
        `startShardId` - the ID of the starting shard.
      Returns:
        a `CloseableIterable` object.

    - #### getPartitioned

          public abstract CloseableIterable<T>[] getPartitioned(Object[] connections,
                                              String key,
                                              Object value,
                                              Class dtValue,
                                              boolean acceptWildcard,
                                              int startShardId)

      Gets an array of `CloseableIterable` objects that hold all the elements with an attribute matching the given K/V pair. Each element in the `CloseableIterable` array uses a separate connection provided to fetch a subset of the results from a corresponding Lucene sub-directory. Note that we assign an integer ID (in the range of [0, N - 1]) to all the sub-directories in a Lucene index with N shards. The subset of shards (subdirectories) queried will consist of those shards with ID value in the range of [startShardId, startShardId - 1 + size of connections array].
      Specified by:
        `getPartitioned` in interface `OracleIndex<T extends Element>`
      Parameters:
        `connections` - an array of connections to the Lucene index. Each element of this array should be of type SearcherManager. See `getOracleSearcherManager(int)`.
        `key` - the key of a property
        `value` - the value object of the property.
        `dtValue` - the class representing the datatype of the property value. This can be used to cast the property value to a different datatype. For example, if the value is "3.01" and dtValue is Float.Class, then this value will be treated as a 3.01f.
        `acceptWildcard` - specifies if wild cards can be used in the value object.
        `startShardId` - the ID of the starting shard.
      Returns:
        a `CloseableIterable` object.

    - #### getSearcherFactory

          public org.apache.lucene.search.SearcherFactory getSearcherFactory()

      Gets the searcher factory associated to this index

    - #### getTotalShards

          public int getTotalShards()

      Gets the number of shards (sub-directories) in this index.
      Specified by:
        `getTotalShards` in interface `OracleIndex<T extends Element>`

    - #### isAutoIndex

          public boolean isAutoIndex()

      Returns true if this is an auto index

    - #### isDelBatchEmpty

          public boolean isDelBatchEmpty()

      Verifies if the deletes batch associated to this index is empty.
      Specified by:
        `isDelBatchEmpty` in interface `OracleIndex<T extends Element>`
      Returns:
        true if the deletes batch is full, else return false.

    - #### isDelBatchFull

          public boolean isDelBatchFull()

      Verifies if the deletes batch associated to this index is full.
      Specified by:
        `isDelBatchFull` in interface `OracleIndex<T extends Element>`
      Returns:
        true if the deletes batch is full, else return false.

    - #### isUpdatesBatchEmpty

          public boolean isUpdatesBatchEmpty()

      Verifies if the updates batch associated to this index is empty.
      Specified by:
        `isUpdatesBatchEmpty` in interface `OracleIndex<T extends Element>`
      Returns:
        true if the updates batch is full, else return false.

    - #### isUpdatesBatchFull

          public boolean isUpdatesBatchFull()

      Verifies if the updates batch associated to this index is full.
      Specified by:
        `isUpdatesBatchFull` in interface `OracleIndex<T extends Element>`
      Returns:
        true if the updates batch is full, else return false.

    - #### put

          public void put(String key,
                 Object value,
                 T element)

      Indexes an element by a key and a value.
      Specified by:
        `put` in interface `Index<T extends Element>`
      Parameters:
        `key` - the key to index the element by.
        `value` - the value to index the element by.
        `element` - the element to index.

    - #### put

          public void put(String key,
                 Object value,
                 T element,
                 OracleIndexWriter[] indexWriters)

      Indexes an element by a key and a value.
      Parameters:
        `key` - the key to index the element by.
        `value` - the value to index the element by.
        `element` - the element to index.
        `indexWriters` - if not null, the cache of indexWriters to use, this avoids opening/closing index writers at flush time, but locks writing operations over the index.

    - #### query

          public final CloseableIterable<T> query(String key,
                                   Object value)

      Query for all the elements satisfying the specified K/V property within the index
      Specified by:
        `query` in interface `Index<T extends Element>`
      Parameters:
        `key` - the key of the K/V property
        `value` - the value object of the K/V property
      Returns:
        a `CloseableIterable` object.

    - #### query

          public final CloseableIterable<T> query(String key,
                                   Object value,
                                   boolean useWildcards)

      Query for all the elements satisfying the specified K/V property within the index
      Specified by:
        `query` in interface `OracleIndex<T extends Element>`
      Parameters:
        `key` - the key of the K/V property
        `value` - the value object of the K/V property
        `useWildcards` - specifies if wild cards can be used in the value object.
      Returns:
        a `CloseableIterable` object.

    - #### remove

          public void remove(String key,
                    Object value,
                    Class dtValue,
                    T element,
                    OracleIndexWriter[] indexWriters)

      Removes an element indexed by a particular key/value.
      Parameters:
        `key` - the key of the indexed element.
        `value` - the value of the indexed element.
        `dtValue` - the data type class of the indexed element.
        `element` - the element to remove given the key/value pair.
        `indexWriters` - if not null, the cache of indexWriters to use, this avoids opening/closing index writers at flush time, but locks writing operations over the index.

    - #### remove

          public void remove(String key,
                    Object value,
                    T element)

      Removes an element indexed by a particular key/value.
      Specified by:
        `remove` in interface `Index<T extends Element>`
      Parameters:
        `key` - the key of the indexed element.
        `value` - the value of the indexed element.
        `element` - the element to remove given the key/value pair.

    - #### remove

          public void remove(String key,
                    Object value,
                    T element,
                    OracleIndexWriter[] indexWriters)

      Removes an element indexed by a particular key/value.
      Parameters:
        `key` - the key of the indexed element.
        `value` - the value of the indexed element.
        `element` - the element to remove given the key/value pair.
        `indexWriters` - if not null, the cache of indexWriters to use, this avoids opening/closing index writers at flush time, but locks writing operations over the index.

    - #### remove

          public void remove(T element)

      Deletes a element from this index
      Specified by:
        `remove` in interface `OracleIndex<T extends Element>`
      Parameters:
        `element` - an `Element` object.
      Throws:
        `IOException`

    - #### removeAll

          public void removeAll(String key)

      Removes all the elements from the index matching the specified key.
      Specified by:
        `removeAll` in interface `OracleIndex<T extends Element>`
      Parameters:
        `key` - the key to remove from the index.

    - #### removeAll

          public void removeAll(String key,
                       OracleIndexWriter[] indexWriters)

      Removes all the elements from the index matching the specified key.
      Parameters:
        `key` - the key to remove from the index.
        `indexWriters` - if not null, the cache of indexWriters to use, this avoids opening/closing index writers at flush time, but locks writing operations over the index.

Copyright © 2015 Oracle and/or its afflilates. All Rights Reserved.